package com.hanrui.android.fragment.message.audit.month;

import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hanrui.android.R;
import com.hanrui.android.library.base.BaseFragment;
import com.hanrui.android.model.OverSeeMonthDetailBean;
import com.hanrui.android.net.contract.message.audit.month.OverSeeMonthDetailContract;
import com.hanrui.android.net.presenter.message.audit.month.OverSeeMonthDetailPresenter;

import butterknife.BindView;

/**
 * 月督办审批基本信息
 *
 */

public class OverSeeMonthDetailFragment extends BaseFragment<OverSeeMonthDetailPresenter> implements OverSeeMonthDetailContract.View {
    @BindView(R.id.main_title)
    TextView mainTitle;
    @BindView(R.id.subhead_title)
    TextView subheadTitle;
   @BindView(R.id.ll_addview)
    LinearLayout lladdview;

    String taskId,procInsId,bizId;

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_overseemonthdetail;
    }

    @Override
    protected void initInjector() { mFragmentComponent.inject(this); }

    @Override
    protected void initView(View view) {

        taskId = getArguments().getString("taskId");
        procInsId = getArguments().getString("procInsId");
        bizId = getArguments().getString("bizId");

        mPresenter.overSeeMonthBizDetail(getActivity(),taskId,procInsId,bizId);

    }



    public static OverSeeMonthDetailFragment newInstance(String taskId, String procInsId, String bizId) {
        OverSeeMonthDetailFragment fragment = new OverSeeMonthDetailFragment();
        Bundle bundle = new Bundle();
        bundle.putString("taskId", taskId);
        bundle.putString("procInsId", procInsId);
        bundle.putString("bizId", bizId);
        fragment.setArguments(bundle);
        return fragment;
    }

    @Override
    public void overSeeMonthBizDetail(final OverSeeMonthDetailBean data) {

        if (null != data) {

            mainTitle.setText(data.getDetail().getName());
            subheadTitle.setText(data.getDetail().getCreateDate());
            if (null != data.getDetail().getList() && data.getDetail().getList().size() > 0) {

                for (int i = 0; i < data.getDetail().getList().size(); i++) {

                    addViewItem(data.getDetail().getList().get(i));
                }

            		}

        }

    }


    //添加ViewItem
    private void addViewItem(final OverSeeMonthDetailBean.DetailBean.ListBean bean) {
        View hotelEvaluateView = View.inflate(getActivity(), R.layout.item_overseemonthdetail, null);
        TextView miniTitle = hotelEvaluateView.findViewById(R.id.mini_title);
        TextView billName = hotelEvaluateView.findViewById(R.id.bill_name);
        TextView thingTitle = hotelEvaluateView.findViewById(R.id.thing_title);
        TextView time = hotelEvaluateView.findViewById(R.id.time);

        miniTitle.setText(bean.getMeetSource());
        billName.setText(bean.getWork());
        thingTitle.setText(bean.getOfficeName());
        time.setText(bean.getTimeNode());


        lladdview.addView(hotelEvaluateView);
    }


}
